package com.fenghongzhang.day012;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MyReceiver5 extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        //发送一个通知
        String action = intent.getAction();
        if(action.equals("com.feng.notify")){
            Notification.Builder builder = new Notification.Builder(context);

            builder.setSmallIcon(R.mipmap.ic_launcher).setContentTitle("标题");

            //没有上下文
            NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

            manager.notify(1,builder.build());
        }
    }
}
